package com.itestor.iptv.utils;

import java.util.List;

import org.apache.log4j.Logger;

/**
 * 
 * @author Mr.li
 *
 */
public class LocalCmdDataParser{   
    
    private static final  Logger logger =Logger.getLogger(LocalCmdDataParser.class);
    
    
    /**
     * 
     * @param scCmdDataLines
     * @return int 
     */
    public static int parseScCmdDataLines(List<String> scCmdDataLines) {
        int state =0;
        for (String readLine : scCmdDataLines) {
            logger.info("read line  :  "+readLine);            
            if (readLine.contains("STATE")) {
                if (readLine.contains("STOPPED")){
                    state=LocalCmdConstant.SC_STATE_STOPTED;
                }else if (readLine.contains("STOP_PEDING")){
                    state=LocalCmdConstant.SC_STATE_STOP_PENDING;
                }else if (readLine.contains("RUNNING")){
                    state=LocalCmdConstant.SC_STATE_RUNING;
                }else if (readLine.contains("STOPTED")){
                    state= LocalCmdConstant.SC_STATE_STOPTED;
                }
                break;
            }else if (readLine.contains("[SC] EnumQueryServicesStatus:OpenService FAILED")){
                state =LocalCmdConstant.SC_SERVICE_NOTEXISTED;
                break;
            }else if (readLine.contains("5:")){
                state =LocalCmdConstant.SC_SERVICE_CONTROL_FAILED;
            }            
        }
        
        return state;
    }
    
}
